package com.lam.common.components.captcha.enums;

import com.lam.common.utils.StringUtils;

public enum CaptchaTypeEnum {
	
	/** 数字公式验证码，3+5=15，4*7=28 等 */
	MATH("math", CaptchaCategoryEnum.CODE),
	/** 字符验证码 */
	CHAR("char", CaptchaCategoryEnum.CODE),
	/** 普通字符验证码(简单易看，但易识别) */
	SIMPLE("simple", CaptchaCategoryEnum.CODE),
	
	/** 滑块拼图. */
    BLOCKPUZZLE("blockPuzzle", CaptchaCategoryEnum.PICTURE),
    /** 文字点选. */
    CLICKWORD("clickWord", CaptchaCategoryEnum.PICTURE),
	;
	
	private CaptchaCategoryEnum category;
	private String name;

	private CaptchaTypeEnum(String name, CaptchaCategoryEnum category) {
		this.name = name;
		this.category = category;
	}

	public String getName() {
		return name;
	}
	
	public static CaptchaTypeEnum value(String name) {
		if(StringUtils.isBlank(name)) {
			return null;
		}
		for (CaptchaTypeEnum v : values()) {
			if(v.name.equalsIgnoreCase(name)) {
				return v;
			}
		}
		return null;
	}

	public CaptchaCategoryEnum getCategory() {
		return category;
	}

}
